home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / iguana / vts139b / lib / basspow.inc < prev    next >
Text File  |  1993-06-02  |  8KB  |  338 lines

  1. P386N
  2.  
  3.  
  4.  
  5. MACRO SumRut Operat
  6.  
  7. RutSum&Operat&_0:
  8.                 RET
  9.  
  10. RutSum&Operat&_1:
  11.                 Sum&Operat&_0    3
  12.                 Sum&Operat&_Last
  13.  
  14. RutSum&Operat&_2:
  15.                 Sum&Operat&_0    2
  16.                 Sum&Operat&_Last
  17.  
  18. RutSum&Operat&_3:
  19.                 Sum&Operat&_0    2
  20.                 Sum&Operat&_1
  21.                 Sum&Operat&_Last
  22.  
  23. RutSum&Operat&_4:
  24.                 Sum&Operat&_0    1
  25.                 Sum&Operat&_Last
  26.  
  27. RutSum&Operat&_5:
  28.                 Sum&Operat&_0    1
  29.                 Sum&Operat&_1
  30.                 Sum&Operat&_0    1
  31.                 Sum&Operat&_Last
  32.  
  33. RutSum&Operat&_6:
  34.                 Sum&Operat&_0    1
  35.                 Sum&Operat&_1
  36.                 Sum&Operat&_Last
  37.  
  38. RutSum&Operat&_7:
  39.                 Sum&Operat&_0    1
  40.                 Sum&Operat&_1
  41.                 Sum&Operat&_1
  42.                 Sum&Operat&_Last
  43.  
  44. RutSum&Operat&_8:
  45.                 Sum&Operat&_Last
  46.  
  47. RutSum&Operat&_9:
  48.                 Sum&Operat&_1
  49.                 Sum&Operat&_0    2
  50.                 Sum&Operat&_Last
  51.  
  52. RutSum&Operat&_10:
  53.                 Sum&Operat&_1
  54.                 Sum&Operat&_0    1
  55.                 Sum&Operat&_Last
  56.  
  57. RutSum&Operat&_11:
  58.                 Sum&Operat&_1
  59.                 Sum&Operat&_0    1
  60.                 Sum&Operat&_1
  61.                 Sum&Operat&_Last
  62.  
  63. RutSum&Operat&_12:
  64.                 Sum&Operat&_1
  65.                 Sum&Operat&_Last
  66.  
  67. RutSum&Operat&_13:
  68.                 Sum&Operat&_1
  69.                 Sum&Operat&_1
  70.                 Sum&Operat&_0    1
  71.                 Sum&Operat&_Last
  72.  
  73. RutSum&Operat&_14:
  74.                 Sum&Operat&_1
  75.                 Sum&Operat&_1
  76.                 Sum&Operat&_Last
  77.  
  78. RutSum&Operat&_15:
  79.                 Sum&Operat&_1
  80.                 Sum&Operat&_1
  81.                 Sum&Operat&_1
  82.                 Sum&Operat&_Last
  83.  
  84. RutSum&Operat&_List DW OFFSET RutSum&Operat&_0
  85.                     DW OFFSET RutSum&Operat&_1
  86.                     DW OFFSET RutSum&Operat&_2
  87.                     DW OFFSET RutSum&Operat&_3
  88.                     DW OFFSET RutSum&Operat&_4
  89.                     DW OFFSET RutSum&Operat&_5
  90.                     DW OFFSET RutSum&Operat&_6
  91.                     DW OFFSET RutSum&Operat&_7
  92.                     DW OFFSET RutSum&Operat&_8
  93.                     DW OFFSET RutSum&Operat&_9
  94.                     DW OFFSET RutSum&Operat&_10
  95.                     DW OFFSET RutSum&Operat&_11
  96.                     DW OFFSET RutSum&Operat&_12
  97.                     DW OFFSET RutSum&Operat&_13
  98.                     DW OFFSET RutSum&Operat&_14
  99.                     DW OFFSET RutSum&Operat&_15
  100.  
  101. ENDM
  102.  
  103.  
  104.  
  105.  
  106. MACRO SumSubR_Last
  107.  
  108.         SAR     EBX,1
  109.         SUB     EAX,EBX
  110.         RET
  111.  
  112. ENDM
  113.  
  114. MACRO SumSubR_1
  115.  
  116.         SAR     EBX,1
  117.         SUB     EAX,EBX
  118.  
  119. ENDM
  120.  
  121. MACRO SumSubR_0 Num
  122.  
  123.         SAR     EBX,Num
  124.  
  125. ENDM
  126.  
  127.                 SumRut  SubR
  128.  
  129.  
  130.  
  131.  
  132. MACRO SumAddR_Last
  133.  
  134.         SAR     EBX,1
  135.         ADD     EAX,EBX
  136.         RET
  137.  
  138. ENDM
  139.  
  140. MACRO SumAddR_1
  141.  
  142.         SAR     EBX,1
  143.         ADD     EAX,EBX
  144.  
  145. ENDM
  146.  
  147. MACRO SumAddR_0 Num
  148.  
  149.         SAR     EBX,Num
  150.  
  151. ENDM
  152.  
  153.                 SumRut  AddR
  154.  
  155.  
  156.  
  157.  
  158. MACRO SumAddL_Last
  159.  
  160.         ADD     EAX,EBX
  161.         RET
  162.  
  163. ENDM
  164.  
  165. MACRO SumAddL_1
  166.  
  167.         ADD     EAX,EBX
  168.         SHL     EBX,1
  169.  
  170. ENDM
  171.  
  172. MACRO SumAddL_0 Num
  173.  
  174.         SHL     EBX,Num
  175.  
  176. ENDM
  177.  
  178.                 SumRut  AddL
  179.  
  180.  
  181.  
  182.  
  183. OfsTrebleFilterVal_Left   DW RutSumSubR_0
  184. OfsTrebleFilterMult_Left  DW RutSumSubR_0
  185. OfsBassFilterVal_Left     DW RutSumSubR_0
  186. OfsBassFilterMult_Left    DW RutSumSubR_0
  187. OfsTrebleFilterVal_Right  DW RutSumSubR_0
  188. OfsTrebleFilterMult_Right DW RutSumSubR_0
  189. OfsBassFilterVal_Right    DW RutSumSubR_0
  190. OfsBassFilterMult_Right   DW RutSumSubR_0
  191.  
  192.  
  193.  
  194.  
  195. FlipTabla DB 0000b, 1000b, 0100b, 1100b, 0010b, 1010b, 0110b, 1110b
  196.           DB 0001b, 1001b, 0101b, 1101b, 0011b, 1011b, 0111b, 1111b
  197.  
  198. MACRO SetFiltValue Band, Operat_Side, Rut
  199.  
  200.                 MOV     AX,[Band&Filter&Operat_Side]
  201.                 ADD     AX,AX
  202.                 MOV     BX,OFFSET RutSum&Rut&_List
  203.                 ADD     BX,AX
  204.                 MOV     AX,[CS:BX]
  205.                 MOV     [CS:Ofs&Band&Filter&Operat_Side],AX
  206.  
  207. ENDM
  208.  
  209. MACRO SetFiltValueFlip Band, Operat_Side, Rut
  210.  
  211.                 MOV     AX,[Band&Filter&Operat_Side]
  212.                 MOV     BX,OFFSET FlipTabla
  213.                 ADD     BX,AX
  214.                 MOV     AL,[CS:BX]
  215.                 ADD     AX,AX
  216.                 MOV     BX,OFFSET RutSum&Rut&_List
  217.                 ADD     BX,AX
  218.                 MOV     AX,[CS:BX]
  219.                 MOV     [CS:Ofs&Band&Filter&Operat_Side],AX
  220.  
  221. ENDM
  222.  
  223. SetFilterValues:
  224.                 SetFiltValue     Treble, Val_Left,   SubR
  225.                 SetFiltValueFlip Treble, Mult_Left,  AddL
  226.                 SetFiltValue     Bass,   Val_Left,   AddR
  227.                 SetFiltValueFlip Bass,   Mult_Left,  AddL
  228.                 SetFiltValue     Treble, Val_Right,  SubR
  229.                 SetFiltValueFlip Treble, Mult_Right, AddL
  230.                 SetFiltValue     Bass,   Val_Right,  AddR
  231.                 SetFiltValueFlip Bass,   Mult_Right, AddL
  232.  
  233.                 RET
  234.  
  235.  
  236.  
  237. ; ┌──────────────────────────────────────────────────────────────────────────┐
  238. ; │                                                                          │
  239. ; │ MACRO: BassPower                                                         │
  240. ; │                                                                          │
  241. ; │ Macro that implements the bass-power equalicer filter.                   │
  242. ; │                                                                          │
  243. ; │ IN:  AX    = 16 bit sample.                                              │
  244. ; │      Side  = Left or Right. For mono, use Left.                          │
  245. ; │                                                                          │
  246. ; │ OUT: idem.                                                               │
  247. ; │                                                                          │
  248. ; │ MODIFIES: AX, BX, CX, DX                                                 │
  249. ; │                                                                          │
  250. ; └──────────────────────────────────────────────────────────────────────────┘
  251.  
  252. MACRO BassPower Side
  253.  
  254.         CWDE
  255.         MOV     ECX,EAX
  256.  
  257.         MOV     EBX,0FFFFFFFFh
  258. @@Data11:
  259.         CALL    [CS:OfsTrebleFilterVal_&Side]
  260.         MOV     [DWORD PTR CS:@@Data11-4],EAX
  261.         MOV     EBX,EAX
  262.         CALL    [CS:OfsTrebleFilterMult_&Side]
  263.         
  264.         XCHG    ECX,EAX
  265.  
  266.         MOV     EBX,0FFFFFFFFh
  267. @@Data21:
  268.         CALL    [CS:OfsBassFilterVal_&Side]
  269.         MOV     [DWORD PTR CS:@@Data21-4],EAX
  270.         MOV     EBX,EAX
  271.         CALL    [CS:OfsBassFilterMult_&Side]
  272.  
  273.         ADD     EAX,ECX
  274.  
  275.         SAR     EAX,2
  276.  
  277.         CMP     EAX,32768
  278.         JNC     SHORT @@satur
  279. @@hecho:
  280.  
  281. MASM
  282. COMMENT %
  283.         MOV     DX,0FFFFh
  284. @@lastdata:
  285.         MOV     BX,DX
  286.         SUB     DX,AX
  287.         ADD     DX,16
  288.         AND     DX,-32
  289.         JNZ     SHORT @@nonext
  290.          MOV    AX,BX
  291. @@nonext:
  292.         MOV     DX,AX
  293.         MOV     [WORD PTR CS:@@lastdata-2],DX
  294. %
  295. IDEAL
  296. ;MOV DX,AX
  297. ;        MOV     AX,DX
  298.         RET
  299.  
  300. @@satur:
  301.         CMP     EAX,-32768
  302.         JNC     SHORT @@hecho
  303.         AND     EAX,EAX
  304.         JS      SHORT @@up
  305.          MOV    EAX,32767
  306.         JMP     SHORT @@hecho
  307. @@up:    MOV    EAX,-32768
  308.         JMP     SHORT @@hecho
  309.  
  310. ENDM BassPower
  311.  
  312. ; ---------------------------------------------------------------------------
  313.  
  314. BassPower_Left:  BassPower Left
  315.  
  316. BassPower_Right: BassPower Right
  317.  
  318. ; ---------------------------------------------------------------------------
  319.  
  320. BassPowerMono   EQU     BassPower_Left
  321.  
  322. ; ---------------------------------------------------------------------------
  323.  
  324. BassPowerStereo:
  325.                 PUSH    BX
  326.                 CALL    BassPower_Left
  327.                 POP     BX
  328.                 PUSH    AX
  329.                 MOV     AX,BX
  330.                 CALL    BassPower_Right
  331.                 MOV     BX,AX
  332.                 POP     AX
  333.                 RET
  334.  
  335.  
  336.  
  337. P286N
  338.